追蹤表
| 步驟 | x |
|---|---|
| 0 | 0 |
| 1 | 2 |
| 2 | 2 |
| 3 | 4 |
| 4 | 4 |
| 5 | 6 |
| 6 | 6 |
| 7 | Output: 6 |
流程圖
偽代碼
1x =
0
2執行
3 x =
x + 2
4當 x
< 5
5輸出 x
Python
1x =
0
2while
True:
3 x =
x + 2
4 if
not (x < 5):
5
break
6print(x)